package com.itheima.type;

public class TypeDemo1 {
    public static void main(String[] args) {
        //目标:认识自动类型转换和强制类型转换
        byte a = 12;
        print(a);   //自动类型性转换,大范围可以接收小范围(int接受byte)
        print2(a);

        System.out.println("----------");

        int i = 10;
        //print3(i);    此时报错，因为int不能接收byte

        byte j= (byte) i;   //强制类型转换
        print3(j);

        int m=1500;
        byte n = (byte) m;
        System.out.println(n);  //出现数据溢出!!!
        System.out.println(m);

        System.out.println("----------");

        double k = 8.66;    //浮点数转换成整数,就是把小数部分去掉
        int l = (int) k;
        System.out.println(l);
    }

    public static void print(int b) {
        System.out.println(b);
    }

    public static void print2(double c) {
        System.out.println(c);
    }

    public static void print3(byte j) {
        System.out.println(j);
    }
}

